"""
字典dict
- {key:value,...}
- key不可以重复
"""

# 定义字典
my_dict1 = {"黄子":99,"石凯":87,"文韬":100}
# 定义空字典
my_dict2 = {}
my_dict3 = dict()
print(f"字典1的内容是：{my_dict1}，类型：{type(my_dict1)}")
print(f"字典2的内容是：{my_dict2}，类型：{type(my_dict2)}")
print(f"字典3的内容是：{my_dict3}，类型：{type(my_dict3)}")

# 定义重复key的字典（只会保留最后一个value) --key不可以重复
my_dict1 = {"黄子":99,"石凯":87,"黄子":90,"文韬":100}
print(f"重复key的字典内容是：{my_dict1}")

# 从字典中基于key获得value（不可以使用下标索引）
my_dict1 = {"黄子":99,"石凯":87,"文韬":100}
value = my_dict1["石凯"]
value2 = my_dict1.get("黄子")
print(f"基于key获得value:{value}")
print(f"基于key获得value2:{value2}")

# 字典的嵌套
# 字典的key和value可以是任意数据类型（key不可为字典）
stu_score_dict = {
    "文韬":{"语文":95,"数学":100,"英语":90},
    "凯凯":{"语文":77,"数学":66,"英语":60},
    "小齐":{"语文":99,"数学":80,"英语":88}
}
print(f"学生的成绩是：{stu_score_dict}")
# 从嵌套字典中获取信息
tao_math_score = stu_score_dict["文韬"]["数学"]
print(f"文韬的数学成绩是：{tao_math_score}")



